package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.pojo.Menu;
import com.itheima.service.MenuService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {
    @Reference
    MenuService menuService;
    @RequestMapping("/getMenu")
    public Result getMenu(){
        List<Menu> menus= menuService.getMenu();
        return new  Result(true,"",menus);
    }

    @RequestMapping("/addMenu")
    public Result addMenu(@RequestBody Menu menu){
        menuService.addMenu(menu);
        return new Result(true,"");
    }

    @RequestMapping("/delMenu")
    public Result delMenu(Integer id){
        menuService.delMenu(id);
        return new  Result(true,"删除菜单成功");
    }
}
